<!DOCTYPE html>
<html ng-app="projectUpdate" ng-cloak>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="/lib/fontAwesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="/lib/navbar/css/responsive-menu.css" rel="stylesheet">
    <link href="/lib/bootstrap-datetime/css/jquery.datetimepicker.css" rel="stylesheet" media="screen">
    <link rel="stylesheet" type="text/css" href="/lib/angular-ui-grid/ui-grid.css"/>
    <link rel="stylesheet" type="text/css" href="/lib/angular-toastr/dist/angular-toastr.css"/>
    <link rel="stylesheet" href="/lib/angular-ui-select/dist/select.css">
    <link rel="stylesheet" href="/lib/jquery-ui/jquery-ui.min.css">
    <link href="/css/style.css" rel="stylesheet">

    <script src="/lib/jquery/jquery.min.js"></script>
    <script src="/lib/jquery/jquery.cookie.min.js"></script>
    <script src="/lib/bootstrap/js/bootstrap.min.js"></script>
    <script src="/lib/navbar/js/modernizr.min.js" type="text/javascript"></script>
    <script src="/lib/navbar/js/modernizr-custom.js" type="text/javascript"></script>
    <script src="/lib/navbar/js/responsive-menu.js" type="text/javascript"></script>

    <script src="/lib/angular/angular.js"></script>
    <script src="/lib/angular-toastr/dist/angular-toastr.tpls.js"></script>
    <script src="/lib/angular-ui-select/dist/select.js"></script>
    <script src="/lib/angular-ui-grid/ui-grid.min.js"></script>
    <script src="/lib/jquery-ui/jquery-ui.min.js"></script>
    <script src="/js/grid-pagination.js"></script>
    <script src="/js/directives.js"></script>
    <script src="/lib/bootstrap-datetime/js/jquery.datetimepicker.js"></script>
    <script src="/js/projectUpdateController.js"></script>

    <title>项目管理</title>
</head>
<body ng-controller="projectUpdateController">
<% var dynamicWidth = '9'; %>

<div class="col-md-12 form-group kick-padding-margin" style="margin-top:10px">
    <span style="display: none;" id="pid"><%- project.p_id %></span>

    <div class="search-area big-panel-container">

        <% if(typeof list !== 'undefined') { %>
        <div class="col-md-3 kick-padding-margin">
            <div class="col-md-12">
                <ul class="list-group" id="pList">
                    <% if(user.role === 'admin') { %>
                    <li class="list-group-item active" id="p-list-1" ng-click="editList(1)"><i
                                style="color:red;float:left">&nbsp;&nbsp;*</i>
                        <i class="fa fa-trash-o remove-icon"></i>&nbsp;<span ng-bind="addList[1].p_name"></span></li>
                    <% } else { %>
                    <% for(var i = 0;i < list.length;i++) { %>
                    <li class="list-group-item <% if(i == 0){ %>active<% } %>" ng-click="edit($event)"
                        id="list-<%- list[i].p_id %>"><%- list[i].p_name %></li>
                    <% } %>
                    <% } %>
                </ul>
                <% if(user.role === 'admin') { %>
                <button ng-click="saveAll()" class="btn btn-success btn-sm col-md-12"><i class="fa fa-save"></i>&nbsp;&nbsp;保存全部
                </button>
                <% } %>
            </div>
        </div>
        <% } else if(project.project_pm) { dynamicWidth = '10 col-md-offset-1'; %>
        <input type="hidden" id="operation" value="adminUpdate">
        <% } else { %>
        <input type="hidden" id="operation" value="adminAdd">
        <% } %>
        <div class="col-md-<%- dynamicWidth %> big-panel">
            <div class="form-group col-md-11 col-md-offset-1">
                <label class="search-label">项目名称</label>
                <input type="text" class="form-control" id="pname" ng-model="query.p_name" value="<%- project.p_name %>"
                       <% if(user.role !== 'admin' || !!project.project_pm) { %>disabled
                        <% } %>
                />
            </div>

            <div class="form-group col-md-11 col-md-offset-1">
                <label class="search-label">项目经理</label>
                <input type="text" class="form-control" id="pm" ng-model="query.pm" value="<%- project.project_pm %>"
                       <% if(user.role !== 'admin') { %>disabled
                        <% } %>
                />
            </div>

            <div class="form-group col-md-11 col-md-offset-1">
                <label class="search-label">研发组长</label>
                <input type="text" class="form-control" id="leader" ng-model="query.leader"
                       value="<%- project.project_leader %>"
                       <% if(user.role !== 'admin') { %>disabled
                        <% } %>
                />
            </div>

            <div class="form-group col-md-11 col-md-offset-1">
                <label class="search-label">项目状态</label>
                <% if(user.role === 'dev' || user.role === 'intern') { %>
                <input type="text" class="form-control" id="status" ng-model="query.status"
                       value="<%- project.status %>" disabled/>
                <% } else { %>
                <ui-select ng-model="query.status" append-to-body="true">
                    <ui-select-match>{{ $select.selected.value }}</ui-select-match>
                    <ui-select-choices repeat="item.id as item in statusMap">
                        <div>{{ item.value }}</div>
                    </ui-select-choices>
                </ui-select>
                <input type="hidden" id='status' value="<%- project.status %>" />
                <% } %>
            </div>

            <div class="form-group col-md-11 col-md-offset-1">
                <label class="search-label">开始时间</label>
                <% if(user.role === 'dev' || user.role === 'intern') { %>
                <input type="text" class="form-control" id="start" ng-model="query.start_date"
                       value="<%- project.start_date %>" disabled/>
                <% } else { %>
                <datetimepicker dateID="start_date" id="start" class="form-control" style="padding: 0"
                                value="<%- project.start_date %>"
                                ng-model="query.start_date" format="Y/m/d"></datetimepicker>
                <% } %>
            </div>

            <div class="form-group col-md-11 col-md-offset-1">
                <label class="search-label">结束时间</label>
                <% if(user.role === 'dev' || user.role === 'intern') { %>
                <input type="text" class="form-control" id="end" ng-model="query.end_date"
                       value="<%- project.end_date %>" disabled/>
                <% } else { %>
                <datetimepicker dateID="end_date" id="end" class="form-control" style="padding: 0"
                                value="<%- project.end_date %>"
                                ng-model="query.end_date" format="Y/m/d"></datetimepicker>
                <% } %>
            </div>

            <div class="col-md-12">
                <% if(user.role === 'admin' && typeof list !== 'undefined') { %>
                <button class="col-md-2 col-md-offset-1 btn btn-warning margin-top-20" ng-click="back()"
                        style="margin-right: 25px;"><i class="fa fa-backward"></i>&nbsp;&nbsp;返回
                </button>
                <% } else if(typeof list !== 'undefined') { %>
                <button class="col-md-2 col-md-offset-3 btn btn-warning margin-top-20" ng-click="back()"
                        style="margin-right: 15px;"><i class="fa fa-backward"></i>&nbsp;&nbsp;返回
                </button>
                <% } else if(!project.project_pm) { %>
                <button class="col-md-2 col-md-offset-3 pull-right btn btn-danger margin-top-20" ng-click="closeModal()"
                        style="margin-right: 15px;"><i class="fa fa-repeat"></i>&nbsp;&nbsp;关闭
                </button>
                <% } else { %>
                <button class="col-md-2 col-md-offset-3 btn btn-warning margin-top-20" ng-click="back()"
                        style="margin-right: 15px;"><i class="fa fa-backward"></i>&nbsp;&nbsp;返回
                </button>
                <% } %>
                <% if(user.role === 'admin' && typeof list !== 'undefined') { %>
                <button class="col-md-2 col-md-offset-1 btn btn-primary margin-top-20" style="margin-right:25px"
                        ng-click="add()">
                    <i class="fa fa-plus"></i>&nbsp;&nbsp;添加一项
                </button>
                <button class="col-md-2 col-md-offset-1 btn btn-info margin-top-20" style="margin-right:25px"
                        ng-click="remove()">
                    <i class="fa fa-minus"></i>&nbsp;&nbsp;移除此项
                </button>
                <% } else if(typeof list !== 'undefined') { %>
                <button class="col-md-2 col-md-offset-1 btn btn-primary margin-top-20" ng-click="save()">
                    <i class="fa fa-save"></i>&nbsp;&nbsp;保存
                </button>
                <% } else if(!!project.project_pm) { %>
                <button class="col-md-2 btn btn-primary col-md-offset-1 margin-top-20" ng-click="save()">
                    <i class="fa fa-save"></i>&nbsp;&nbsp;保存
                </button>
                <% } else { %>
                <button class="col-md-2 col-md-offset-1 btn btn-primary pull-right margin-lr margin-top-20"
                        ng-click="save()">
                    <i class="fa fa-save"></i>&nbsp;&nbsp;保存
                </button>
                <% } %>
            </div>
        </div>
    </div>

    <div class="modal fade  remove-prj" style="position: absolute;top:40px;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">确认移除该项目？</h4>
                </div>
                <div class="modal-body" style="height: 70px;">
                    <button type="button" class="btn btn-success col-md-2 pull-right" id="ensure-remove">确认</button>
                    <button type="button" class="btn btn-warning col-md-2 pull-right" style="margin-right: 20px"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

</div>
<script>
    $(function ($) {
        var menu = $('.rm-nav').rMenu({
            minWidth: '960px'
        });
    });
</script>
</body>
</html>